/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package managedBeans.util;

import java.util.List;
import javax.faces.model.SelectItem;

/**
 *
 * @author David
 */
public class JsfUtil {
     public static SelectItem[] getSelectItems(List<?> entities, boolean selectOne) {
         
        int size = selectOne ? entities.size()  : entities.size();
        SelectItem[] items = new SelectItem[size];
        int i = 0;
//        if (selectOne) {
//            
//            items[0] = new SelectItem("", "---");
//            i++;
//        }
        for (Object x : entities) {
//            System.out.println(x.toString());
            items[i++] = new SelectItem(x, x.toString());
        }
        return items;
    }
}
